//
//  LQVisitorTableViewController.swift
//  Weibo
//
//  Created by ios on 16/8/8.
//  Copyright © 2016年 ios. All rights reserved.
//

import UIKit

class LQVisitorTableViewController: UITableViewController {
    //是否登录的标记
    var islogin: Bool = LQUserAccountViewModel.shareUserAccount.isLogin
    
    var visitorView: LQVisitorView?
    override func loadView() {
        if islogin {
        super.loadView()
            
        } else{
        //使用自己定义的视图
        visitorView = LQVisitorView()
        visitorView?.loginClosure = { [weak self] in
         self?.reqeustOAuthVC()
            
            }
             view = visitorView
            //  设置导航栏按钮
            setNavUI()
        }
        
    }
    override func viewDidLoad() {
        super.viewDidLoad()
    }
   private func setNavUI(){
    
    navigationItem.leftBarButtonItem  =  UIBarButtonItem(title: "注册", target: self, action: "registerAction")
    navigationItem.rightBarButtonItem  =  UIBarButtonItem(title: "登录", target: self, action: "loginAction")
    }
    
     @objc private  func loginAction(){
     print("登录")
     reqeustOAuthVC()
    }
    @objc private  func registerAction(){
        print("注册")
       reqeustOAuthVC()
        
    }
    
    //  登录第三方的函数
    private func reqeustOAuthVC() {
        
        let OauthVc = LQOAuthViewController()
        
          print("aaaa1111=====")
        
        let nav = UINavigationController(rootViewController: OauthVc)
        
        presentViewController(nav, animated: true) { () -> Void in
            print("我又出来了")
        }
    }
}
